﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="RemotingLogClient.cs" company="">
//   
// </copyright>
// <summary>
//   The remoting log client.
// </summary>
// --------------------------------------------------------------------------------------------------------------------


using System;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Ipc;
using Systemathics.FrameWork.Interfaces;

namespace Systemathics.FrameWork
{
    [Serializable]
    public sealed class RemotingLogClient
    {
        private readonly ILogMessage m_ILogMessage;

        public RemotingLogClient()
        {
            var m_ipc = new IpcClientChannel();
            if (m_ipc == null)
                ChannelServices.RegisterChannel(m_ipc, false);
            m_ILogMessage =
                (ILogMessage) Activator.GetObject(typeof (ILogMessage), "ipc://MessageServer/MessageServer.rem");
        }

        public void Trace(FireMessageEventArgs e)
        {
            try
            {
                m_ILogMessage.Trace(e);
            }
            catch (Exception)
            {
            }
        }
    } 
}